package top.xiaoshuaila.moments.mapper;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.sql.Timestamp;

@Repository
public interface ZanMapper {
    @Select("select COUNT(*)>0 from zan where zan.dyid=${dyid} and zan.userid=${userid}")
    boolean iszan(long dyid, long userid);

    @Delete("delete from zan where zan.userid=${userid} and zan.dyid=${dyid}")
    void removezan(long dyid, long userid);

    @Insert("insert into zan (dyid,userid,time)values (${dyid},${userid},'${time}')")
    void addzan(long dyid, long userid, Timestamp time);

    @Insert("insert into userdy (userid,time,iszhuan,dyid,selfonly)values (${userid},'${time}',${iszhuan},'${dyid}',${selfonly})")
    void adddy(long userid, Timestamp time, boolean iszhuan, String dyid, boolean selfonly);
    @Select("select count(*) from userdy where userdy.id=${dyid}")
    int gettotal(long dyid);
}
